package com.xbongbong.paas.service.stage;

import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

/**
 * 阶段记录策略工厂
 * @author 李少杰
 * @version v1.0.0
 * @date 2021/11/23 14:30
 */
@Component
public class StageLogHandleFactory {

    @Resource
    private Map<Integer, StageLogHandle> stageLogHandleMap;

    public StageLogHandle getStageLogHandle(Integer saasMark, Integer businessType) {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark) || (Objects.equals(saasMark, SaasMarkEnum.SAAS.getCode()) && Objects.equals(businessType, XbbRefTypeEnum.CONTRACT.getCode()))) {
            return stageLogHandleMap.get(XbbRefTypeEnum.PAAS.getCode());
        } else {
            return stageLogHandleMap.get(businessType);
        }
    }
}
